<template>
  <a-card :bordered="false">

    <!-- 查询区域 -->
    <div class="table-page-search-wrapper">
      <a-form layout="inline">
            <a-form-item label="机构">
              <ak-tree-select-multiple :url="sysDepartUrl.tree" v-model="queryParam.depart.value"/>
            </a-form-item>
            <a-form-item label="网站名称">
              <a-input autocomplete="off" placeholder="请输入姓名查询" v-model="queryParam.name.value"></a-input>
            </a-form-item>
            <a-form-item label="域名">
              <a-input autocomplete="off" placeholder="请输入账号查询" v-model="queryParam.domain.value"></a-input>
            </a-form-item>
          <a-form-item>
            <span  class="table-page-search-submitButtons">
              <a-button type="primary" @click="searchQuery" icon="search">查询</a-button>
              <a-button type="primary" @click="searchReset" icon="reload" >重置</a-button>
              <a-button @click="handleAdd"  type="primary" icon="plus">新增</a-button>
              <a-button  type="danger" icon="delete" v-if="selectedRowKeys.length > 0"  @click="batchDel">批量删除</a-button>
            </span>
          </a-form-item>

      </a-form>
    </div>


    <!-- table区域-begin -->
    <div>
      <div class="ant-alert ant-alert-info" style="margin-bottom: 16px;">
        <i class="anticon anticon-info-circle ant-alert-icon"></i>已选择&nbsp;<a style="font-weight: 600">{{ selectedRowKeys.length }}</a>项&nbsp;&nbsp;
        <a style="margin-left: 24px" @click="onClearSelected">清空</a>
      </div>

      <a-table
        ref="table"
        bordered
        size="middle"
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        :rowSelection="{selectedRowKeys: selectedRowKeys, onChange: onSelectChange}"
        @change="handleTableChange">

        <template slot="file" slot-scope="text, record">
          <ak-file-preview :value="text"></ak-file-preview>
        </template>
        <span slot="ellipsis" slot-scope="text">
              <ak-ellipsis :value="text" :length="25"/>
            </span>
        <span slot="action" class="table-operator" slot-scope="text, record">
          <a   @click="handleEdit(record)">编辑</a>
           <a   @click="handleDelete(record.id)">删除</a>
        </span>


      </a-table>
    </div>
    <!-- table区域-end -->

    <cms-modal ref="modalForm" @ok="modalFormOk"></cms-modal>


  </a-card>
</template>

<script>
  import AkfhListMixin from '../../mixin/AkfhListMixin';
  import {sysDepartUrl,cmsUrl} from '../../api/url'
  import AkTreeSelectMultiple from "../../components/akfh/AkTreeSelectMultiple";
  import AkFilePreview from "../../components/akfh/file-preview/AkFilePreview";
  import CmsModal from './modal/CmsModal'
  import AkEllipsis from '../../components/akfh/AkEllipsis'

  export default {
    name: "CmsList",
    mixins: [AkfhListMixin],
    components: {
      AkEllipsis,
      CmsModal,
      AkFilePreview,
      AkTreeSelectMultiple,
    },
    data() {
      return {
        queryParam: {
          depart:{
            column:'sysDepart.id',
            type:'in',
            value:''
          },

          name:{
            type:'like',
            value:'',
            column:'name'
          },
          domain:{
            type:'like',
            value:'',
            column:'domain'
          },
        },

        columns: [
          {
            title: '#',
            dataIndex: '',
            key:'rowIndex',
            width:60,
            align:"center",
            customRender:function (t,r,index) {
              return parseInt(index)+1;
            }
          },
          {
            title: '机构',
            align: "center",
            dataIndex: 'sysDepartName',
            scopedSlots: {customRender: 'ellipsis'},
          },

          {
            title: '域名',
            align: "center",
            dataIndex: 'domain',
            scopedSlots: {customRender: 'ellipsis'},
          },
          {
            title: '网站名称',
            align: "center",
            dataIndex: 'name',
            scopedSlots: {customRender: 'ellipsis'},
          },

          {
            title: '版权copyright',
            align: "center",
            dataIndex: 'copyright',
            scopedSlots: {customRender: 'ellipsis'},
          },
          {
            title: '备案号',
            align: "center",
            dataIndex: 'recordNum',
            scopedSlots: {customRender: 'ellipsis'},
          },
          {
            title: 'logo',
            align: "center",
            dataIndex: 'logo_fileUrl',
            scopedSlots: {customRender: "file"}
          },

          {
            title: '标题',
            align: "center",
            dataIndex: 'title',
            scopedSlots: {customRender: 'ellipsis'},
          },
          {
            title: '关键字',
            align: "center",
            dataIndex: 'keywords',
            scopedSlots: {customRender: 'ellipsis'},
          },
          {
            title: '页面描述',
            align: "center",
            dataIndex: 'description',
            scopedSlots: {customRender: 'ellipsis'},
          },
          {
            title: 'js 增强',
            align: "center",
            dataIndex: 'scriptAdd',
            scopedSlots: {customRender: 'ellipsis'},
          },
          {
            title: 'css 增强',
            align: "center",
            dataIndex: 'styleAdd',
            scopedSlots: {customRender: 'ellipsis'},
          },
          {
            title: '操作',
            dataIndex: 'action',
            scopedSlots: {customRender: 'action'},
            align: "center",
            width: 250
          }

        ],
        url: cmsUrl,
        sysDepartUrl:sysDepartUrl,
      }
    },
    mounted(){
    },
    methods: {

    }

  }
</script>
<style scoped>
  @import "../../assets/less/common.less";
</style>
